package org.thraex.excel.utils;

import lombok.extern.log4j.Log4j2;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.thraex.excel.vo.DetailVO;

import java.util.List;
import java.util.concurrent.CountDownLatch;

/**
 * @Author 鬼王
 * @Date 2019/08/12 11:01
 */
@Log4j2
public class ExportExcelOrgThread extends Thread {

    private final Object obj = new Object();

    private String month;

    private CellStyle titleCellStyle;

    private XSSFWorkbook wb;

    private List<DetailVO> detailVOS;

    private DetailVO detailVO1;

    private CountDownLatch countDownLatch;


    @Override
    public void run() {
        try {
//            synchronized (detailVO1) {
//                log.info(this.detailVO1.getDeptName());
                System.out.println("run: " + this.detailVO1.getDeptName() + ", " + Thread.currentThread());
//            }
        } catch (Exception e) {
            log.error("run方法： " +  e.getMessage());
            e.printStackTrace();
        } finally {
            if (countDownLatch != null) {
//                log.info("conut down");
                countDownLatch.countDown();
            }
        }
    }

    public void setDetailVO1(DetailVO detailVO1) {
        this.detailVO1 = detailVO1;
    }

    public void setMonth(String month) {
        this.month = month;
    }

    public void setTitleCellStyle(CellStyle titleCellStyle) {
        this.titleCellStyle = titleCellStyle;
    }

    public void setWb(XSSFWorkbook wb) {
        this.wb = wb;
    }

    public void setCountDownLatch(CountDownLatch countDownLatch) {
        this.countDownLatch = countDownLatch;
    }

    public void setDetailVOS(List<DetailVO> detailVOS) {
        this.detailVOS = detailVOS;
    }
}
